home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Fades ƒ / Slide fade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.6 KB  |  93 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Slide fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 1
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short SlideFade(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* Split the screen into 10 sections, then scroll each section left or right
  38.    (alternating), starting with the top section and working towards the bottom. */
  39.    
  40. pascal short SlideFade(Rect boundsRect, Pattern *thePattern)
  41. {
  42.     int                x, y;
  43.     Rect            dest;
  44.     Rect            scrollsource;
  45.     int                direction;
  46.     int                BoxSize, StripSize;
  47.     
  48.     BoxSize=theWindowWidth/25;
  49.     StripSize=theWindowHeight/10;
  50.     
  51.     direction = 0;
  52.     for(y = 0; y < theWindowHeight; y += StripSize)
  53.     {
  54.         scrollsource = boundsRect;
  55.         scrollsource.top+=y;
  56.         scrollsource.bottom = scrollsource.top + StripSize;
  57.         
  58.         dest = scrollsource;
  59.         if(direction == 0)
  60.         {
  61.             dest.right=dest.left+BoxSize;
  62.         
  63.             for(x = boundsRect.right - BoxSize; x >= boundsRect.left; x -= BoxSize)
  64.             {
  65.                 StartTiming();
  66.                 ScrollRect(&scrollsource, BoxSize, 0, 0L);
  67.                 SectRect(&dest, &boundsRect, &dest);
  68.                 FillRect(&dest, *thePattern);
  69.                 TimeCorrection(CorrectTime);
  70.             }
  71.             FillRect(&scrollsource, *thePattern);
  72.         }
  73.         else
  74.         {
  75.             dest.left = dest.right - BoxSize;
  76.             
  77.             for(x = boundsRect.left+BoxSize; x <= boundsRect.right; x += BoxSize)
  78.             {
  79.                 StartTiming();
  80.                 ScrollRect(&scrollsource, -BoxSize, 0, 0L);
  81.                 SectRect(&dest, &boundsRect, &dest);
  82.                 FillRect(&dest, *thePattern);
  83.                 TimeCorrection(CorrectTime);
  84.             }
  85.             FillRect(&scrollsource, *thePattern);
  86.         }
  87.         
  88.         direction = 1 - direction;
  89.     }
  90.     
  91.     return 0;
  92. }
  93.